clear; close all; addpath('../utilities');

load model_solution omega stat stat_Q
load model_simulation
load model_simulation_pop

omega_states    = omega(states);
E_omega_sim     = mean(omega_states(:));
SD_omega_sim    = std(omega_states(:));

E_omega     = omega'*stat;
E_omega2    = omega.^2'*stat;
SD_omega    = sqrt( E_omega2 - E_omega.^2 );

EQ_omega     = omega'*stat_Q;
EQ_omega2    = omega.^2'*stat_Q;
SDQ_omega    = sqrt( EQ_omega2 - EQ_omega.^2 );

table = [[E_omega_sim; SD_omega_sim; nan; nan; table_7], ...
    [E_omega; SD_omega; EQ_omega; SDQ_omega; table_7_pop]];

row_labels = {'Average bankruptcy costs under P','Std. dev. of bankruptcy costs under P',...
    'Average bankruptcy costs under Q','Std. Dev. of bankruptcy costs under Q',...
    'Average 5-year PD under P','Average 5-year PD under Q',...
    'Std. dev. of 5-year PD under P','Std. dev. of 5-year PD under Q',...
    'Average LGD under P','Average LGD under Q'};

col_labels = {'Model','Population'};
Opts.Style = 'jf'; Opts.digit='r'; format = '%.2f';
disp(Mat2TexC(table*100,format,row_labels,col_labels,[],Opts,'Credit Market Moments'))


